//
//  MyTableViewController.m
//  UI13-AutoLayout(强化)
//
//  Created by 韩旭 on 16/8/1.
//  Copyright © 2016年 lanou. All rights reserved.
//
#define WIDETH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
#define COLORAUTO [UIColor colorWithRed:(arc4random()%256/255.0) green:(arc4random()%256/255.0) blue:(arc4random()%256/255.0) alpha:1.0]
#import "MyTableViewController.h"
#import "HX_TableViewCell.h"
#define kTableViewCellResue @"reuse"
@interface MyTableViewController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSArray *arrDataSource;

@end

@implementation MyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.arrDataSource = @[@"sfdsfsfsdfsdf水电费水电费水电费水电费水电费水电费水电费水电费水电费水电费", @"fdfsdfsdf", @"dfsdfsdfsdfsdffff"];
//    1. 自定义cell self-sizing iOS 8以后出的
//    效率低, 系统计算
//    预估高度
    self.tableView.estimatedRowHeight = 40;
//    高度 (自动计算高度)
//    self.tableView.rowHeight = UITableViewAutomaticDimension;
    
//    2. 根据lable内容, 计算高度, 并赋予tableView
    
//    好处, 可以存储高度, 可以省掉部分计算的时间
    
    
//    1. 常用的有先级  优先级分为4档1000 750 250 50
//    2. 高优先级会先被执行，根据情况, 低优先级可能被舍弃
//    3. 优先级一般被用来解决约束冲突的问题（解决约束冲突, 找关键的数字）
//    4. 优先级1000. 在sb/xib中为实现，低于1000的优先级一般为虚线
//    5. 我们还可以用优先级来做动画效果
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
//    
//}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return _arrDataSource.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HX_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCellResue forIndexPath:indexPath];
    cell.backgroundColor = COLORAUTO;
    cell.lableName.text = _arrDataSource[indexPath.row];
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
